Kameleon-Plus  0.3.2
HDF5FileReader.h
Go to the documentation of this file.
1 /*
2  * HDFFileReader.h
3  *
4  * Created on: July 12, 2011
5  * Author: David Berrios
6  */
7 // #ifndef HDFFILEREADER_H_
8 // #define HDFFILEREADER_H_
9 #include "Kameleon-plus-Config.h"// #include "config.h"
10 #ifdef HAVE_HDF5
11 #include <string>
12 #include <vector>
13 #include <iostream>
14 #include "Attribute.h"
15 #include <boost/unordered_map.hpp>
16 #include "H5Cpp.h"
17 #include "FileReader.h"
18 
19 
20 namespace ccmc
21 {
22 
30  class HDF5FileReader : public FileReader
31  {
32  private:
33  //boost::unordered_map<long, std::string> variable_names;
34 
35  public:
36 
37  HDF5FileReader();
38  std::vector<float>* getVariable(const std::string& variable);
39  std::vector<float>* getVariable(long variable);
40  std::vector<float>* getVariable(const std::string& variable, long startIndex, long count);
41  std::vector<float>* getVariable(long variable, long startIndex, long count);
42  float getVariableAtIndex(const std::string& variable, long index);
43  float getVariableAtIndex(long variable_id, long index);
44  std::vector<int>* getVariableInt(const std::string& variable);
45  int getVariableIntAtIndex(const std::string& variable, long index);
46  int getNumberOfGlobalAttributes();
47  int getNumberOfVariables();
48  int getNumberOfVariableAttributes();
49  long getNumberOfRecords(const std::string& variable);
50  long getNumberOfRecords(long variable_id);
51  long getVariableID(const std::string& variable);
52  std::string getVariableName(long variable_id);
53  Attribute getGlobalAttribute(long i);
54  std::string getGlobalAttributeName(long attribute_id);
55  std::string getVariableAttributeName(long attribute_id);
56  Attribute getGlobalAttribute(const std::string& attribute);
57  long getGlobalAttributeID(const std::string& attribute);
58  Attribute getVariableAttribute(const std::string& variable, const std::string& attribute);
59  std::vector<std::string> getVariableAttributeNames();
60  bool doesAttributeExist(const std::string& attribute);
61  bool doesVariableExist(const std::string& variable);
62  const std::string& getCurrentFilename();
63  virtual ~HDF5FileReader();
64 
65 
66  protected:
67  std::string current_filename;
68  H5::H5File * current_file;
69  H5::Group * rootGroup;
70  H5::Group * variableGroup;
71  long closeFile();
72  long openFile(const std::string& filename, bool readonly);
73  void initializeGlobalAttributes();
74  void initializeVariableAttributes();
75  void initializeVariableIDs();
76  void initializeVariableNames();
77 
78  };
79 }
80 #endif /* HAVE_HDF5 */
81 // #endif /* HDFFILEREADER_H_ */